package com.onjob.message;

import java.util.Date;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;

public class MessageAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private MessageDao messageDao;
	private Message message;
	private String id;
	private List<Message> results;  
	
	
	public List<Message> getResults() {
		return results;
	}
	public void setResults(List<Message> results) {
		this.results = results;
	}
	public MessageDao getMessageDao() {
		return messageDao;
	}
	public void setMessageDao(MessageDao messageDao) {
		this.messageDao = messageDao;
	}
	public Message getMessage() {
		return message;
	}
	public void setMessage(Message message) {
		this.message = message;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String execute(){
//		Message msg = new Message();
//		msg.setMessageContent("aa");
//		msg.setVisible(0);
//		this.messageDao.create(msg);
		System.out.println(this.messageDao.hasNotReadMessage("111").size());
		return SUCCESS;
	}
	public String addMessage(){
		message.setMessageCreateTime(new Date());
		this.messageDao.create(message);
		return SUCCESS;
	}
	public String setReadTag(){
		this.messageDao.setReadTag(id);
		return SUCCESS;
	}
	public String deleteMessage(){
		this.messageDao.delete(this.message);
		return SUCCESS;
	}
	public String seleteMessage(){
		results = this.messageDao.hasNotReadMessage(id);
		return SUCCESS;
		
	}
	
}
